{extend name="$_admin_base_layout" /}
{block name="body"}
<div class="container-fluid" style="padding-top: 10px; background-color: rgb(240, 242, 245);">
    <div class="row">
        <div class="pull-left">
            <ul class="nav nav-pills">
                <li class=""><a href="{:url('index')}"><i
                        class="icon icon-reply"></i> 返回</a></li>
                <li class="" style="padding-left: 0; padding-right: 0; padding-top: 8px;">
                    <strong style="border-left: 1px solid #ddd;display: inline-block; padding-left: 15px;">{$meta_title}</strong> [{$info.title}]
                </li>
            </ul>
        </div>
    </div>
    <form action="{:url('')}" class="form-horizontal" method="post">
        {notempty name="rule_list"} {volist name="rule_list" id="rule"}
        <div class="panel panel-auth-group" style="margin-bottom: 0;">
            <div class="panel-heading">
                <label class="checkbox-inline"> <input class="auth_rules rules_all" type="checkbox" name="rules[]"
                                                       value={$rule.id} {$rule.checked}>
                    <strong>{$rule.title}</strong>
                </label>
                <label class="checkbox-inline" style="padding-left: 0;">
                    [ <a class="btn-select-all" href="###">全选</a> <a class="btn-cancel-all" href="###">取消</a> ]
                </label>
            </div>
            <div class="panel-body">
                {notempty name="rule._child"}{volist name="rule._child" id="child"}
                <div class="rule_check">
                    <div>
                        <label class="checkbox-inline">
                            <input class="btn-rule-row" type="checkbox" name="rules[]" value="{$child.id}"
                                   {$child.checked}>
                            <strong>{$child.title}</strong>
                        </label>
                    </div>
                    {notempty name="child._child"}
                    <div class="child_row" style="padding-left: 20px;">
                        {volist name="child._child" id="data"} <label class="checkbox-inline"> <input
                            class="auth_rules rules_row" type="checkbox" name="rules[]" value="{$data.id}"
                            {$data.checked}>
                        {$data.title}
                    </label> {/volist}
                    </div>
                    {/notempty}
                </div>
                {/volist} {else/}
                <p style="margin-bottom: 0;" class="text-center">aOh! 该菜单下暂时还没有内容!</p>
                {/notempty}
            </div>
        </div>


        {/volist} {else/}
        <p class="text-center">aOh! 暂时还没有内容!</p>
        {/notempty}


        <div class="panel panel-auth-group" style="margin-bottom: 0; margin-top: 10px;">
            <div class="panel-body">
                <input type="hidden" name="id" value="{$info.id|default=''}">
                <button class="btn btn-primary ajax-post" type="submit" data-href="form-horizontal">
                    <i class="icon icon-save"></i> 保存
                </button>
                <a class="btn btn-default" href="{:url('index')}">
                    <i class="icon icon-undo"></i> 返回
                </a>
            </div>
        </div>
    </form>
</div>

</form>
</div>
{/block}
{block name="script"}
<script>
    $(function () {
        $('.panel-heading .btn-select-all').click(function () {
            $panel = $(this).parents('.panel-auth-group');
            $panel.find("input[type='checkbox']").prop('checked', true);
        });
        $('.panel-heading .btn-cancel-all').click(function () {
            $panel = $(this).parents('.panel-auth-group');
            $panel.find("input[type='checkbox']").prop('checked', false);
        });

        $('.btn-rule-row').click(function () {
            $panel = $(this).parents('.rule_check');
            if ($(this).is(':checked')) {
                $panel.children('.child_row').find("input[type='checkbox']").prop('checked', true);
            } else {
                $panel.children('.child_row').find("input[type='checkbox']").prop('checked', false);
            }
        });
    });

</script>
{/block}